# This is a sample Python script.

# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.


from __future__ import print_function
import torch


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press ⌘F8 to toggle the breakpoint.


def test():
    # 直接分配一个 5行3列的矩阵
    torch_empty = torch.empty(5, 3)
    print(torch_empty)
    # 分配一个 5行3列的矩阵，并且 random [1,0]
    torch_rand = torch.rand(5, 3)
    print(torch_rand)
    # 分配一个 5行3列 并且初始值为 0的矩阵，并且指定数据类型为 long 类型
    torch_zero = torch.zeros(5, 3, dtype=torch.long)
    print(torch_zero)
    # 直接通过数据创建张量
    torch_tensor = ([2.5, 3.5])
    print(torch_tensor)

    torch_ones = torch_empty.new_ones(5, 3, dtype=torch.double)
    print(torch_ones)
    # 输出张量的尺寸 torch.Size([5, 3])
    # torch.Size 返回的是一个元祖，所以对于所有的元祖操作都可以直接在上面进行使用
    print(torch_ones.size())


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')
    test()

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
